﻿@{
    ViewBag.Title = "Employee";
}

@section scripts
{ 
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
}
        @Html.Partial("~/Views/Modular/ToolBarBaseEx.cshtml")
        @Html.Partial("~/Views/Modular/SearchInfo.cshtml")
        <div class="mini-fit">
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
                    borderStyle="border:1;" url="GetList"
                    allowCellSelect="true" allowCellEdit="true"showColumnsMenu="true"fitColumns="false"  
                    onrowdblclick="modify"  sortMode="client">
                <div property="columns">
                    <div type="checkcolumn" >选行</div>
                    <div type="indexcolumn" width="40" headerAlign="center" >序号</div>
                    <div field="FNumber" name="FNumber" width="80" headeralign="center" allowsort="true">编码</div>
                    <div field="FName" name="FName" width="100" headeralign="center" allowsort="true">导购姓名</div>
                    <div field="FTelephone" name="FTelephone" width="100" headeralign="center" allowsort="true">联系电话</div>
                    <div header="商品销售提成" headerAlign="center">
                        <div property="columns">
                            <div field="FPerTypeName" name="FPerTypeName" width="160" headeralign="center" allowsort="true">提成方式</div>
                            <div field="FSalePer" name="FSalePer" width="70" headeralign="center" allowsort="true" numberFormat="#,0.00##" align="right">提成系数</div>
                        </div>
                    </div>
                    <div header="会员充值提成" headerAlign="center">
                        <div property="columns">
                            <div field="FRecPerName" name="FRecPerName" width="270" headeralign="center" allowsort="true">提成方式</div>
                            <div field="FRecPer" name="FRecPer" width="70" headeralign="center" allowsort="true" numberFormat="#,0.00##" align="right">充值提成</div>
                        </div>
                    </div>
                    <div header="次卡提成" headerAlign="center">
                        <div property="columns">
                            <div field="FTimePerName" name="FTimePerName" width="180" headeralign="center" allowsort="true">提成方式</div>
                            <div field="FTimePer" name="FTimePer" width="70" headeralign="center" allowsort="true" numberFormat="#,0.00##" align="right">次卡提成</div>
                        </div>
                    </div>                                      
                    <div field="FStateName" name="FStateName" width="80" headeralign="center" allowsort="true">状态</div>
                    <div field="FRemark" name="FRemark" width="150" headeralign="center" allowsort="true">其它说明</div>
                </div>
            </div>
        </div>
<script>
    mini.parse();
    function FormShown() {
        LoadListData();
    }


   //加载资料列表
    function LoadListData() {
        var sSystemAppID = parent.window.getSystemAppID();
        var json = "[{";
        json = json + "'FSystemAppID':" + "'" + sSystemAppID + "',";
        json = json + "'search':" + "'" + mini.getbyName("FSearchKey").getValue() + "'";
        json = json + "}]";
        var grid = mini.get("datagrid1");//==
        grid.load({ mjson: json });
    }

    //搜索资料列表
    function search() {
        LoadListData();
    }

    //刷新
    function refresh() {
        mini.getbyName("FSearchKey").setValue('');
        LoadListData();
    }

    ///增加资料
    function newBill() {
        var uID = parent.window.getSystemAppID();
        mini.open({
            url: "/Employee/EmployeeInfo",
            title: "导购员资料", width: 800, height: 400,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new", FItemID: "0" };
                iframe.contentWindow.SetInfoData(data);
            },
            ondestroy: function (action) {
                var grid = mini.get("datagrid1");
                grid.reload();
            }
        });
    }

    //修改资料
    function modify() {
        if (!mini.get("edit").getVisible()) return;
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/Employee/EmployeeInfo",
                title: "导购员资料", width: 800, height: 400,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "edit", FItemID: row.FItemID };
                    iframe.contentWindow.SetInfoData(data);
                },
                ondestroy: function (action) {
                    var grid = mini.get("datagrid1");
                    grid.reload();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    //删除资料
    function removeInfo() {
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        var FSystemAppID = parent.window.getSystemAppID();
        if (row) {
            mini.confirm("确定要删除选中的记录吗？", "提示",
                function (action) {
                    if (action == "ok") {
                        var json = "{'FItemID':'" + row.FItemID + "'}";
                        $.post("RemoveInfo", { json: json, mSystemAppID: FSystemAppID }, function (data) {
                            var ret = mini.decode(data);
                            if (ret.status == 1) {
                                grid.reload();
                            }
                            else {
                                mini.alert("异常:" + ret.error);
                            }
                        });
                    }
                });
        } else {
            mini.alert("请选中一条记录");
        }
    }

</script>